< previous page page_266 next page >

Page 266
The results? The hNameMappings field was always zero, no matter what I tried or what files I copied. Zero. NULL. Nada.
I was about ready to decide that it was a Windows bug when, on a lark, I tried it on Windows 95 (most of my development is under NT 4.0). Bingo! A non-zero value appeared any time a file rename occurred.
And no, there is nothing in Microsoft's documentation to suggest that this feature is not supported under NT 4.0. It just isn't.1
Reading the Array
Now that I had a "handle," I had to figure out what to do with it. The documentation suggested that the handle contained an array of SHNAMEMAPPING structures. From this it was natural to conclude that the handle was a pointer to an array of these structures. So I wrote the following code:
' Perform a copy operation
Private Sub DoACopy()
   Dim sh As SHFILEOPSTRUCT
   Dim src$, dest$
   Dim res&
   Dim NameMapping As SHNAMEMAPPING
   Dim OriginalName As String
   Dim FinalName As String

   src$ = GetNullsString(FileList)
   dest$ = "A:\" & Chr$(0) & Chr$(0)

   sh.hwnd = hwnd
   sh.wFunc = FO_COPY
   sh.pFrom = src$
   sh.pTo = dest$
   sh.fFlags = FOF_RENAMEONCOLLISION Or FOF_WANTMAPPINGHANDLE
   sh.hNameMappings = 0


   res = DoTheShellCall(sh, "Files are being copied to floppy")

   If sh.hNameMappings <> 0 Then
      RtlMoveMemory NameMapping, ByVal sh.hNameMappings, _
      Len(NameMapping)
      If NameMapping.cchOldPath <> 0 Then
         OriginalName = String$(NameMapping.cchOldPath + 1, Chr$(0))

 
< previous page page_266 next page >